import { localRead, localSave } from "@/lib/local"
export default {
  state: {
    isCollapse: false, //判断导航是否收缩
    routeList: localRead("routeList"), //路由列表
    routeTree: localRead("routeTree"), //路由树
    currentPosition: localRead("currentPosition"), //当前位置
    recordRoute: localRead("recordRoute") || [],
  },
  mutations: {
    setRoute: (state, routeList) => {
      state.routeList = routeList
      localSave("routeList", routeList)
    },
    setIsCollapse: (state, isCollapse) => {
      state.isCollapse = isCollapse
    },
    setRouteTree: (state, routeTree) => {
      state.routeTree = routeTree
      localSave("routeTree", routeTree)
    },
    setCurrentPosition: (state, currentPosition) => {
      state.currentPosition = currentPosition
      localSave("currentPosition", currentPosition)
    },
    setRecordRoute: (state, recordRoute) => {
      state.recordRoute = recordRoute
      localSave("recordRoute", recordRoute)
    },
  },
}
